import React, { Component,lazy,Suspense } from 'react'
import { HashRouter as Router, Route, Switch,Redirect } from "react-router-dom"

import NotFound from '../pages/NotFound'
// import A1 from '../pages/A1';

// import Mine from '../pages/Mine'
let  Main  = lazy(()=>import ("../pages/Main"));
let Login  = lazy(()=>import ("../pages/Login"));


export default class index extends Component<any, any> {

    constructor(props:any){
        super(props);
        this.state = {
            routerList:[{id:1,path:"/",component:Login,exact:true},{id:2,path:"/main",component:Main}]

        }
    }

    render() {
        return (
            <Router>
                <Suspense fallback={<div>Loading...</div>}>
                <Switch>
                    {this.state.routerList.map((item:any)=>{
                        return <Route key={item.id} path={item.path} component={item.component} exact={item.exact}></Route>

                    })}
                    {/* <Route path="/a1" component={A1}></Route> */}
                    <Route path="/404" component={NotFound}> </Route>
                    <Redirect to="/404" path='*'></Redirect>
                </Switch>
                </Suspense>
            </Router>
        )
    }
}
